package cn.iocoder.yudao.module.system.controller.admin.statistics;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.system.controller.admin.statistics.vo.OverallRespVO;
import cn.iocoder.yudao.module.system.controller.admin.workorder.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.workorder.vo.StatisticsPageReqVO;
import cn.iocoder.yudao.module.system.service.workorder.WorkOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 统计管理")
@RestController
@RequestMapping("/system/statistics")
@Validated
public class WorkController {

    @Resource
    private WorkOrderService workOrderService;


    @GetMapping("/overallStatistics")
    @Operation(summary = "整体统计")
    public CommonResult<PageResult<OverallRespVO>> overallStatistics(@Valid StatisticsPageReqVO pageReqVO) {

        PageResult<OverallRespVO> pageResult = workOrderService.overallStatistics(pageReqVO);
        return success(pageResult);
    }
    @GetMapping("/dailyReport")
    @Operation(summary = "每日生产")
    public CommonResult<PageResult<DailyRespVO>> dailyReport(@Valid StatisticsPageReqVO pageReqVO) {

        PageResult<DailyRespVO> pageResult = workOrderService.dailyReport(pageReqVO);
        return success(pageResult);
    }
    @GetMapping("/dailyProduction")
    @Operation(summary = "日常报表(未完)")
    public CommonResult<PageResult<WorkOrderRespVO>> dailyProduction(@Valid StatisticsPageReqVO pageReqVO) {
        PageResult<WorkOrderRespVO> pageResult = workOrderService.dailyProduction(pageReqVO);
        return success(pageResult);
    }
    @GetMapping("/productionDetails")
    @Operation(summary = "生产明细(未完)")
    public CommonResult<PageResult<WorkOrderRespVO>> productionDetails(@Valid StatisticsPageReqVO pageReqVO) {
        PageResult<WorkOrderRespVO> pageResult = workOrderService.productionDetails(pageReqVO);
        return success(pageResult);
    }
    @GetMapping("/summaryOutputAll")
    @Operation(summary = "产值汇总（全部客户）")
    public CommonResult<PageResult<SummaryRespVO>> summaryOutputAll(@Valid StatisticsPageReqVO pageReqVO) {
        PageResult<SummaryRespVO> pageResult = workOrderService.summaryOutputAll(pageReqVO);
        return success(pageResult);
    }

    @GetMapping("/summaryOutputDy")
    @Operation(summary = "产值汇总（单一客户）")
    public CommonResult<PageResult<SummaryRespVO>> summaryOutputDy(@Valid StatisticsPageReqVO pageReqVO) {
        PageResult<SummaryRespVO> pageResult = workOrderService.summaryOutputDy(pageReqVO);
        return success(pageResult);
    }

}
